package com.example.hotel.service.impl;

import com.example.hotel.dao.EmailMessageRecordDao;
import com.example.hotel.entity.EmailMessageRecord;
import com.example.hotel.service.EmailMessageRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (EmailMessageRecord)表服务实现类
 */
@Service("emailMessageRecordService")
public class EmailMessageRecordServiceImpl implements EmailMessageRecordService {
    @Resource
    private EmailMessageRecordDao emailMessageRecordDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public EmailMessageRecord queryById(Integer id) {
        return this.emailMessageRecordDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<EmailMessageRecord> queryAllByLimit(int offset, int limit) {
        return this.emailMessageRecordDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param emailMessageRecord 实例对象
     * @return 实例对象
     */
    @Override
    public EmailMessageRecord insert(EmailMessageRecord emailMessageRecord) {
        this.emailMessageRecordDao.insert(emailMessageRecord);
        return emailMessageRecord;
    }

    /**
     * 修改数据
     *
     * @param emailMessageRecord 实例对象
     * @return 实例对象
     */
    @Override
    public EmailMessageRecord update(EmailMessageRecord emailMessageRecord) {
        this.emailMessageRecordDao.update(emailMessageRecord);
        return this.queryById(emailMessageRecord.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.emailMessageRecordDao.deleteById(id) > 0;
    }

    /**
     * 查询所有数据
     */
    public List<EmailMessageRecord> queryAll(EmailMessageRecord emailMessageRecord) {
        return this.emailMessageRecordDao.queryAll(emailMessageRecord);
    }

    /**
     * 通过指定字段查询单条数据
     */
    @Override
    public EmailMessageRecord queryByName(EmailMessageRecord emailMessageRecord) {
        return this.emailMessageRecordDao.queryByName(emailMessageRecord);
    }

}